package shuashuami.hb.com.avtivity.agent;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

import shuashuami.hb.com.avtivity.AbActivity;
import shuashuami.hb.com.fragment.CYongJinMingxiFragment;
import shuashuami.hb.com.fragment.agent.YongJinMingxiFragment;
import shuashuami.hb.com.hbclient.R;
import shuashuami.hb.com.hdlibrary.util.fragment.ZoomOutPageTransformer;
import shuashuami.hb.com.view.PagerSlidingTabStrip;

public class YongJinMingxiActivity extends AbActivity {

    private ViewPager contentPager;
    private mPagerAdapter adapter;
    private PagerSlidingTabStrip tabs;

    private YongJinMingxiFragment cdistributionFragment1;
    private YongJinMingxiFragment cdistributionFragment2;

    @Override
    protected void initUI() {
        setAbContentView(R.layout.activity_cyong_jin_mingxi);
        contentPager = (ViewPager) findViewById(R.id.content_pager_cdistribution);
        adapter = new mPagerAdapter(getSupportFragmentManager());
        contentPager.setAdapter(adapter);
        contentPager.setOffscreenPageLimit(2);
        contentPager.setPageTransformer(true, new ZoomOutPageTransformer());

        tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs_cdistribution_center);
        tabs.setTextColorResource(R.color.gray);
        tabs.setDividerColorResource(R.color.view_unpressed);
        tabs.setIndicatorColorResource(R.color.blue);
        tabs.setSelectedTextColorResource(R.color.blue);
        tabs.setIndicatorHeight(4);
        tabs.setUnderlineHeight(2);
        tabs.setTextSize(12);
        tabs.setViewPager(contentPager);
    }

    @Override
    protected void initData() {
        setTitleBar("佣金明细");
        setLeftView();
        cdistributionFragment1 = new YongJinMingxiFragment();
        cdistributionFragment1.setType("1");
        cdistributionFragment2 = new YongJinMingxiFragment();
        cdistributionFragment2.setType("2");
    }

    @Override
    protected void initListener() {

    }

    private class mPagerAdapter extends FragmentStatePagerAdapter {

        private String Title[] = {"单刷佣金", "分销佣金"};

        public mPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int arg0) {
            // int[] id = { 5, 18, 27, 37, 21, 36, 23, 24 };
            if (arg0 == 0) {
                return cdistributionFragment1;
            } else {
                return cdistributionFragment2;
            }
        }

        @Override
        public int getCount() {
            return Title.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return Title[position];
        }

    }
}
